import { setGlobal } from '@swda/utils'


let SWDAWindowManager = {};
SWDAWindowManager.commandShopMenuButtonImage = 'MenuButton_BuySell'


//-----------------------------------------------------------------------------
// SWDA_Window_ShopMenuCommand
//
// The window for selecting a command on the menu screen.
class SWDA_Window_ShopMenuCommand extends SWDA_Window_Command_4Arrows {
    constructor() {
        super(...arguments)
        this.initialize(...arguments);
    }

    initialize(purchaseOnly) {
        this._purchaseOnly = purchaseOnly;
        super.initialize(0, 0)
        this.selectLast();
        this.createButtons(SWDAWindowManager.commandShopMenuButtonImage);
    }
    windowWidth() {
        return 240
    }

    numVisibleRows() {
        return this.maxItems()
    }

    initCommandPosition() {
        this._lastCommandSymbol = null;
    }



    makeCommandList() {
        this.addMainCommands();
    }

    addMainCommands() {
        this.addCommand('', '', false);
        this.addCommand(TextManager.buy, 'buy', true);
        this.addCommand(TextManager.cancel, 'cancel');
        this.addCommand(TextManager.sell,   'sell',   !this._purchaseOnly);
    }


    processOk() {
        SWDA_Window_ShopMenuCommand._lastCommandSymbol = this.currentSymbol();
        Window_Command.prototype.processOk.call(this);
    }

    selectLast() {
        this.selectSymbol(SWDA_Window_ShopMenuCommand._lastCommandSymbol);
    };

}
SWDA_Window_ShopMenuCommand._lastCommandSymbol = null;



setGlobal('SWDA_Window_ShopMenuCommand', SWDA_Window_ShopMenuCommand)